
<div class="input-dropzone" style="width: 270px; height: 172px;" id="{{$name}}">
    <div class="input-dropzone__item">
        <div class="input-dropzone__container">

            <div class="input-dropzone__preview pixel-pattern pixel-pattern--darker input-dropzone__preview--show" style="display: none" id="{{$name}}_div"><img id="{{$name}}_div_show" width="270px" height="168px" @if($value) src="{{imagecache('imagecache',['template'=>'thumb','filename'=>$value])}}" @endif alt=""></div>
            <div class="input-dropzone__preview pixel-pattern pixel-pattern--darker"></div>
            <div class="input-dropzone__help" id="{{$name}}_help">
                <div class="input-dropzone__help__centerer">
                    <div class="input-dropzone__help__image"><img src="{{asset('images/drop-upload.png')}}" width="36" height="23" type="png" class=""></div>
                    <div class="input-dropzone__help__text"><span><!-- react-text: 6485 --><font style="vertical-align: inherit;">@lang('web.onclick_upload_image')</font></span></div>
                </div>
            </div>
        </div>
<input type="hidden" name="{{$name}}" id="{{$name}}_val" value="{{$value or ''}}">
    </div></div>
<script>
    @if($value)
    $("#{{$name}}_div").show();
    $("#{{$name}}_help").hide();
    @endif
    layui.use('upload',function(){
        var $=layui.jquery,upload=layui.upload;
        var success = humane.create({baseCls: 'humane-jackedup', addnCls: 'humane-jackedup-success'});
        var error = humane.create({baseCls: 'humane-jackedup', addnCls: 'humane-jackedup-error'});
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $(".layui-upload-file").hide();
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#{{$name}}',
            url: '{{route('image_upload')}}',
            method:'post',
            drag:true,
            before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $("#{{$name}}_div").show();
                    $('#{{$name}}_div_show').attr('src', result); //图片链接（base64）
                });

            }
            ,done: function(res){
                if(res.code==undefined){
                    return error.log('{{trans('message.system_busy')}}');
                }
                //如果上传失败
                if(res.code > 0){
                    return error.log(res.msg);
                }
                //上传成功
                console.log(res.data.src);
                $("#{{$name}}_val").val(res.data.src);
                $("#{{$name}}_help").hide();
                return success.log(res.msg);
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#upload_imageText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    });
</script>